package com.ctshk.rpc.order.custom.mapper;


import com.ctshk.rpc.order.custom.base.CustomBaseMapper;
import com.ctshk.rpc.order.custom.entity.CustomizedOrderTouristFeeAdjust;
import com.ctshk.rpc.order.custom.vo.TouristCollectionFeeJson;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * <p>
 * 游客应收调整费用 Mapper 接口
 * </p>
 *
 * @author 叶冠峰
 * @since 2021-02-22
 */
public interface CustomizedOrderTouristFeeAdjustMapper extends CustomBaseMapper<CustomizedOrderTouristFeeAdjust> {

    /**
     * 根据旅客清空旧数据
     * @param orderId
     * @param touristId
     * @param userId
     */
    @Update("UPDATE t_customized_order_tourist_fee_adjust\n" +
            "SET is_deleted = 1,modified_id = #{modified_id}\n" +
            "WHERE order_id = #{order_id} AND tourist_id = #{tourist_id} AND is_deleted = 0")
    Integer cleanByTourist(@Param("order_id") Long orderId,@Param("tourist_id") Long touristId,@Param("modified_id") Long userId);

    /**
     * 获取旅客调整费用列表
     * @param touristId
     * @return
     */
    @Select("SELECT `name` AS projectName,amount AS totalAmount,plus_type AS adjustType\n" +
            "FROM t_customized_order_tourist_fee_adjust\n" +
            "WHERE tourist_id = #{tourist_id} AND is_deleted = 0")
    List<TouristCollectionFeeJson> queryByTourist(@Param("tourist_id")Long touristId);
}
